<? session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Adoptable Pet - Kalamazoo Animal Rescue</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<? include("./includes/head.inc");  ?>

<style type="text/css">
<!--
div.content p {
	margin-top:1em;
}

div.float {
  float: left;
  }
  
div.float p {
   text-align: center;
   font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #333333; 
   padding-top: 1px; padding-right: 3px; padding-left: 3px
   }

div#mainphoto img.mainphoto {
	border: 3px double #6f6f6f;
	margin: 0px 3px 3px 3px;
}

div#tnphoto img.tnphoto {
	border: 1px #6f6f6f solid;
	margin: 3px;
}
-->
</style>
</head>

<body>

<!--initial body width and height set up  -->
<div id="bodywidth">
<? include("./includes/header.inc");  ?>
<? include("./includes/leftmenu.inc");  ?>
<!--<? include("./includes/photoBlock.php");  ?>-->

<!--wide2column enter here -->
<div id="wide2column">
<p align="center"> 

  <!-- Altered file to handle both available and adoptable pets.  Made adopted.php obsolete. -->

<?php
include("./includes/db.php");					// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect


if (preg_match('/^(D|d)/', $displaypet)){
	$type = "dogs";
}
else if ((preg_match('/^(C|c)/', $displaypet)) || (preg_match('/^(SC|sc)/', $displaypet))){
	$type = "cats";
}
else{
	echo("<p>Pet type error</p>");
	printf('Pet type is: %s', $displaypet);
}

$showing = @mysql_query("SELECT * FROM eventPets, $type
			WHERE eventPets.tagNum=$type.tagNum AND $type.tagNum='$displaypet'");
			
$num_rows = mysql_num_rows($showing);

if ($num_rows <> 0) {
		echo("<div style=\"clear:both;\">");
		echo("<img src=\"images/note1.gif\" width=\"79\" height=\"77\" align=\"left\" hspace=\"5\" alt=\"Make a Note\"><BR>");               
		while ( $row = mysql_fetch_array($showing) )  {			// while there is data
		$id = $row["tagNum"];
		$name =  $row["pet_name"];
		$date = $row["eventDate"]; 
		//  Get YYYY-MM-DD
		list($year, $month, $day) = explode("-", $date); 
		$showMonth = date("l, F j, Y", mktime(0,0,0,$month,$day,$year));
		$a_time = $row["arrive_time"];
		$b_time = $row["depart_time"];
		$eventID = $row["eventID"];

		echo ("On ". $showMonth . ", ".$name." will be at ");

		$event = @mysql_query("SELECT * FROM events
								WHERE eventID='$eventID' ");
		while ($row = mysql_fetch_array($event) )  	{		

			echo ("<A HREF=\"http://02d2e0a.netsolhost.com/sched2.php?eventID=".$eventID."\">");
					
			$eventLoc = $row["location_id"];
		        $query = "SELECT * FROM locations WHERE location_id = ".$eventLoc;
			$locationInfo = mysql_fetch_array(@mysql_query($query));
			$eventName = $locationInfo["name"];
			$friendlyLoc = $locationInfo["friendly_address"];		
			
		    if(($eventLoc == 3)||($eventLoc == 4)) {
		    	$eventName = substr($eventName, 0, 17);
			}
    
			if ($friendlyLoc != "")
				echo($eventName." on ".$friendlyLoc."</a>");
			else
				echo($eventName."</a>");

		}
		echo (" from ".$a_time ." - ".$b_time . "<BR>");
	} // end while
	echo ("<BR clear=all><HR><BR>");
	echo("</div>");
}  // end if
?>

</p>
<p>

  <?php
// $result = @mysql_query("SELECT * FROM pets, petPics, fosterHome 
//				  WHERE pets.pet_id=petPics.pet_id AND
//				  pets.pet_mom=fosterHome.parent_id AND 
//				  pets.pet_id='$displaypet'");
if ($type == "cats"){
$result = @mysql_query("SELECT * FROM cats, volunteers
				  WHERE cats.volunteer_id=volunteers.volunteer_id AND 
				  cats.tagNum='$displaypet'");
}
else{
$result = @mysql_query("SELECT * FROM dogs, volunteers
				  WHERE dogs.volunteer_id=volunteers.volunteer_id AND 
				  dogs.tagNum='$displaypet'");
}
if (!$result) {
  echo("<p>Error performing query: " . mysql_error() . "</p>");
  exit();
}

while ( $row = mysql_fetch_array($result) ) {       // pull the record info on the pet
	$temp_id = $row["tagNum"];
	$name = $row["pet_name"];
	$noPhotos=$row["noPhotos"];
	$adoptFee = $row["adoptFee"];
	$status = $row["pet_status"];
	$gender = $row["pet_sex"];
	//$pfAge = $row["pf_age"];
	$microchipped = $row["microchipped"];
	$scc_cat = $row["scc_cat"];
	$petDOB = $row["pet_DOB"];
	$breed1 = $row["primaryBreed"];
	$breed2 = $row["secondaryBreed"];
	$petMixed = $row["pet_mixed"];
	$petSize = $row["pet_size"];
	$noCats = $row["noCats"];
	$noDogs = $row["noDogs"];
	$specNeed = $row["spec_need"];
	$noKids = $row["noKids"];
	$declawed = $row["declaw"];
	$foster_home = $row["display_name"];
	$type = $row["pet_type"];
	if (strrchr($foster_home, "&")) { $multiple=1; }  //  looking for 'Mike & Sue' type names
  	$description = $row["description"];

//*************************************************************
//***   Assign proper word for "His/Her/Their foster mom is ...
//*************************************************************
  if ($row["pet_sex"] == 'm'):	
        $pronoun = 'His'; 
        $scc_pro = "him";
		$gender = "Male";
   elseif ($row["pet_sex"] == 'f'):
		$pronoun = 'Her';
		$scc_pro = "her";
		$gender = "Female";
   else:
		$pronoun = 'Their';
		$gender = "Group";
   endif;

//*************************************************************
// *********       Display Photo Block
//*************************************************************
/*
if (!$noPhotos) {   // If there are associated photos for this pet, show them
	echo("<div style=\"float:right;margin-left:5px\">");
	photoBlock($displaypet);    // call to function in includes/photoBlock.php
	echo("</div>");
	}
	*/
//*************************************************************
// *********       Start Text Display on Page
//*************************************************************
if ($status=='a'){
	echo("<H2>Adopted Animal</H2>");
	echo("<center><img src=\"../images/dogs/thmbnail/adopted.gif\" align=middle width=\"76\" height=\"76\" alt=\"Adopted\"></center><BR>");
} else {
	echo("<CENTER><H2>Adoptable Animal</H2></CENTER>");
}

//*************************************************************
// *********       Display Pet Detail Block
//*************************************************************

		$prim_breed = @mysql_query("SELECT breedName from petfinderBreeds 
					where breedID='$breed1'");
		$prim = mysql_fetch_array($prim_breed);
		$breed1 = $prim["breedName"];

		$sec_breed = @mysql_query("SELECT breedName from petfinderBreeds 
					where breedID='$breed2'");
		$sec = mysql_fetch_array($sec_breed);
		$breed2 = $sec["breedName"];

	list($year, $month, $day) = explode('-', $petDOB);
	$DOB = mktime(0, 0, 0, $month, $day, $year);
	
	switch ($petSize) {
		case "S":
    			$petSize="Small";
		    	break;
		case "M":
    			$petSize="Medium";
		    	break;
		case "L":
    			$petSize="Large";
		    	break;
		case "XL":
    			$petSize="Extra-Large";
		    	break;
	}

	echo("<div style='float:left;margin-left:10px;'>");
	echo("<H2>".$name."</H2><BR>");
	echo("<div style='width:275px;background:#eee;padding:5px;border:1px solid gray;'>");
	echo("<span style='font-size:90%'>");
	if ($petMixed==1) {
		$mix = " <I>Mix</I><BR>";
	   } else {
		$mix = "<BR>";
	   }
	echo($breed1);
	if ($breed2 <> "") {
		echo(",  ".$breed2.$mix);
	} else {
		echo $mix;
	}
//******************************************
//  ***      Print any special symbols
//******************************************
	echo("<div style='float:right;margin-right:11px'>");

	echo("<a href=\"legend.htm\" target='_blank'>");
	if ($specNeed=='1'):		// special needs
		echo("<p><img SRC=\"02d2e0a.netsolhost.com/images/sneed5.gif\" border=0 HSPACE=0 ALIGN=\"TOP\" WIDTH=\"24\" HEIGHT=\"24\" ALT=\"Special Needs\"></p>");
	endif;

	if ($declawed=='1'):		// declawed
		echo("<p><img SRC=\"http://02d2e0a.netsolhost.com/images/declawed3.gif\" border=0 HSPACE=0 ALIGN=\"TOP\" WIDTH=\"24\" HEIGHT=\"24\" ALT=\"Declawed\"></p>");
	endif;

	if ($noKids=='1'):		// no kids
		echo("<p><img SRC=\"http://02d2e0a.netsolhost.com/images/noKid.gif\" border=0  HSPACE=0 ALIGN=\"TOP\" WIDTH=\"24\" HEIGHT=\"24\" ALT=\"No Kids\"></p>");
	endif;

	if ($noCats=='1'):		// no cats
		echo("<p><img SRC=\"http://02d2e0a.netsolhost.com/images/noCat.gif\" border=0  HSPACE=0 ALIGN=\"TOP\" WIDTH=\"24\" HEIGHT=\"24\" ALT=\"No Cats\"></p>");
	endif;

	if ($noDogs=='1'):		// no dogs
		echo("<p><img SRC=\"http://02d2e0a.netsolhost.com/images/noDog.gif\" border=0 HSPACE=0 ALIGN=\"TOP\" WIDTH=\"24\" HEIGHT=\"24\" ALT=\"No Dogs\"></p>");
	endif;
	echo("</a>");
	echo("</div>");		// end special symbol div

	echo("<div style='margin-left:17px;'>");
	echo("Size: ".$petSize."<BR>");
	echo("Age: ".$pfAge."<BR>");
	echo("Approx DOB: ". date('n/d/y', $DOB)."<BR>");
	echo("Gender: ".$gender."<BR>");
	if ($microchipped=='1')  
		{ echo("Microchipped<BR>"); }
	echo("</div>");
	echo("</span>");
	echo("</div>");	
	echo("</div>");	

//*************************************************************
//***    Set path to look in cat or dog images and applications
//*************************************************************
   if ($type == 'c'):	
      $path = "http://02d2e0a.netsolhost.com/images/cats/";
      if ($scc_cat) {
		$a_form ="http://02d2e0a.netsolhost.com/forms/catadopt.php?SCC=1";
	  } else {
		$a_form = "http://02d2e0a.netsolhost.com/forms/catadopt.php";
	  }
  else:
      $path = "http://02d2e0a.netsolhost.com/images/dogs/";
      $a_form = "http://02d2e0a.netsolhost.com/forms/dogadopt.php";
	  $a_kdtc = "http://www.kdtc.org/";
   endif;
}

 echo("<div class='content' style='clear:left;'><BR>");
 echo("$description"); 	// print out the description block of text
 echo("<BR><BR>");

if ($status=='a') {  	// if the pet is marked as adopted
	if (isset($multiple)) {
		$stmt = $pronoun ." foster parents were " .  $foster_home.".";
		echo $stmt . "</div>";
		}
	else {
		$stmt = $pronoun ." foster parent was " .  $foster_home.".";
		echo $stmt . "</div>";
		}
	// end if 
} else {		// if the pet is anything but adopted
	if (isset($multiple)) {
		$stmt = $pronoun ." foster parents are " .  $foster_home.".";
		}
	else {
		$stmt = $pronoun ." foster parent is " .  $foster_home.".";
		}
	// end if 

	if ($adoptFee=='') {   // if fee is blank just leave that statement out
		$fee = "";
	} else {
		$fee= 'The adoption fee for '.$name . ' is $' . $adoptFee.'.';
	if ($type == 'c') {
			$fee = $fee.'  If more than one cat or kitten is adopted the adoption fees are discounted.';
		}
	}

//*****************************************************
// *********    Wording for Dogs *********************
//*****************************************************
$dogStuff = "<P>".$stmt ."&nbsp;&nbsp;".$fee. "<P>Please complete our <a href='" . $a_form ."'>online application form</a> if you are interested in adopting ".$name . ".   A volunteer will contact you. <b><font color = #ff00ff>Please be patient with us. We are all volunteers who donate our time.</font></b></P>

<P>All Kalamazoo Animal Rescue dogs & puppies are spayed or neutered prior to adoption. Dogs have been heartworm tested and if appropriate (age and time of year) all dogs and puppies are given heartworm preventative. All are given medication to rid them of roundworms and checked and treated for fleas & ear mites, if needed. Dogs and puppies are given distemper vaccines and depending on how long the pet has been in foster care, additional distemper vaccine(s) may be necessary and the expense will be incurred by the adopter. Any canine over 4 months of age is brought current on the Rabies vaccine. Additional vet care may have been provided depending on the particular animal's needs. <b>Dogs are individually priced as above.</b> </p>

<P>It is in the best interest of pooch and owner to enroll in an obedience class soon after adoption. After all, you have a lot to learn about your new friend. The <a href='" . $a_kdtc ."'>Kalamazoo Dog Training Club</a> offers a discount to owners with newly adopted dogs. Enroll before any behavior problems start - you won't regret it!</p>";

//*****************************************************
// *********    Wording for Cats *********************
//*****************************************************
$sccText = "<P>".$name . " is part of our Senior Cat Companions program, which means anyone can adopt " .$scc_pro. ", but an adopter who is 60 and older may adopt " .$scc_pro. " at a reduced adoption fee.</P> ";

if ($scc_cat) {
	$catStuff = $sccText."<P>".$stmt ."&nbsp;&nbsp;<P>Please complete our <a href='" . $a_form ."'>online application</a> form if you are interested in adopting ".$name . ".  A volunteer will contact you within approximately 24-48 hours. </P>";
	} else { 
	$catStuff = "<P>".$stmt ."&nbsp;&nbsp;".$fee. "<P>Please complete our <a href='" . $a_form ."'>online application</a> form if you are interested in adopting ".$name . ".  A volunteer will contact you within approximately 24-48 hours.</P>"; 
	}
$catStuff .=  "<P>All Kalamazoo Animal Rescue cats & kittens are spayed or neutered and feline leukemia tested prior to adoption. They also are given medication to rid them of roundworms and checked and treated for fleas & ear mites, if needed. Additional vet care may have been provided depending on the particular animal's needs. All are given distemper vaccinations and depending on how long the pet has been in foster care, additional vaccine(s) may be necessary and the expense will be incurred by the adopter.  </p>";

	if ($type =='d') {
		echo $dogStuff;
	} else {
		echo $catStuff;
	}
	echo ("<BR><BR></div>");   // ends class=content div
}  // end if status = a
?>
</p>
</div>
<? include("./includes/footer.inc");  ?>
<!--tag below ends bodywidth div -->
</div>
</body>
</html